#!/usr/bin/env node

//TODO:循环
/*  */
const log = console.log,
      { stdin, stdout } = process,
      msg = ['Name', 'Email', 'QQ', 'Mobile'];

let me = {}, i = 1;
//不同于console.log，不会回车
stdout.write(msg[0] + ': ');

stdin.on('data', (data) => {
  //去掉换行符且转为字符串
  me[msg[i-1]] = data.slice(0, data.length - 1).toString('utf8');
  if(i === 4) {
    log(me);
    process.exit();
  }

  stdout.write(msg[i++] + ': ');
});

stdin.on('end', () => {
  log(me);
});


